SERIAL COMMS USING AGILENT VEE.

This takes you through the various steps required to achieve a serial
comms link and also points out some tips on the way.

The steps take you through installing the IO software, setting up an
'instrument' which will be the serial device and sending and receiving
serial data.  Comments, ideas for improvements etc are very welcome -
please use the Questions/Answers/Comments form on the website -
www.PreciselySo.Co.UK

DISCLAIMER, WARRANTY AND COPYRIGHT
These examples are provided on an 'as is' basis with no explicit or
implied warranty.  Copyright is retained by the author but free use
including copying and use for business purposes is expressly permitted.

This explanation goes with a set of VEE files that you should also have
- they are in VEE 6 as this includes improvements over VEE 5 for I/O
handling.  If you would like a VEE 5 version please send a request via
the website.

Step 1.
If you have not already done so load the Agilent IO Libraries.  This
should have been shipped with your copy of VEE.  If you already have
this loaded ( or you have loaded a VISA library from another
manufacturer ) then you can omit this stage.

Once loaded, it should automatically configure your interfaces - if not
run the 'IOConfig' program ( read the IO Libraries documentation and run
this program ).

If you press the 'Auto Add' button it should add one or two serial
ports depending on how many are built into your computer.  If you have a
GPIB board ( IEEE-488 ) then it should add this too.

You should have a blue 'IO' icon in your system tray showing that the
Agilent IO Library Control is active.


Step 2.
Run VEE and open the Instrument Manager ( under the I/O menu ).  Press
the 'Find Instruments' button whilst 'My Configuration' is selected -
this should find all devices on all interfaces linked to the computer.
It should include the one or two serial ports seen in the IOConfig
program from Step 1.

Click on the serial interface you want to use for your device and press
'Add'

Type the details into this dialog box before pressing the 'Advanced...'
button.

Now you can enter all the details for the device - you can set up
drivers if you have them in the normal way but the information on the
'Serial' tab is required for the serial protocol settings.


Step 3.
Return to the instrument manager screen and ( assuming you do not have
any drivers for the device ) press the 'Direct IO' button to obtain a
transaction box for the device which you can use for sending and
receiving data from the device sonnected to the serial port.

You can then use this to read and write from/to the port.

TIPS FOR USING THE SERIAL PORT.

If you are used to using GPIB comms this will come as a bit of a
surprise - GPIB is pretty rugged for communicating whereas serial lines
depend much more that both ends know exactly what is happening.

Troubleshooting tool 1
Use another PC instead of the device you want to control and use Windows
'Hyperterminal' ( or similar program ) connected 'direct to Com1'.  Set
the serial properties as you have in the VEE instrument manager i.e.
Baud rate, no of characters, no of stop bits, parity and flow control.
Once connected you should see characters being written to the remote
computer and you can type responses to your VEE program as well.

Troubleshooting tool 2
Under the I/O menu you will see Bus IO Monitor - this shows every
character sent and received on the bus being examined for
troubleshooting purposes.  You can even log this to disk if required.

You will see an error saying that VEE cannot set the Baud rate if the
computer cannot support such a rate ( e.g. my WinNT machine only
supports up to 115200 Baud ).

Writing Tips:
Generally, writing is easier than reading because the computer knows
what to expect.  The main stumbling block is usually the terminator for
the data - VEE defaults to "\n" [new line] but you may want to set this
to "\r" [return] or even "\r\n".  You can do this on the 'Direct IO' tab
in the advanced properties of the instrument manager settings, or you
can add it to the end of your data - see Serial 1.vee example.  This
example was set up with 115200/8/1/even/Xon-Xoff serial settings
running on WinNT 4/VEE Pro 6 to a Win95 machine running Hyperterminal
connected via a null-modem cable ( HP 24542U ).

Reading tips:
If you have set up a serial link similar to the one I have used, look at
Serial 2 example.  If you run the program then type something on the
remote computer ( within the IO timeout ) nothing appears to happen
until you press the return key, when the message you typed appears.
This is because I have set up the IO configuration to use '\r' as the
termination character.

This is not always convenient because your device may have no specific
termination character.  If this is the case you may want to read byte-
by-byte and work out what is going on yourself, either by counting
bytes, or by looking for a specific character.

Serial 3 example shows this.  For the second example, there is an error
output pin added to the serial IO transaction box.  This ignores timeout
errors ( and all others too! ) but is a better way of allowing a long
timeout rather than setting it in the device:  setting a large timeout
will stop the program while VEE waits for the data and prevent anything
else happening ( including you trying to stop the program ).
